package com.sfj.system.enums;

import com.sfj.system.dto.DeptDTO;

import java.util.ArrayList;
import java.util.List;

/**
 * @author kaka
 * @Date 2025/06/28
 */
public enum DeptEnum {

    OFFICE(1, "办公室"),
    POLICY_LEGAL(2, "政策法制处"),
    POLITICAL_DEPT(3, "政治部"),
    ORG_PROPAGANDA(4, "组织宣传处"),
    HR_DEPT(5, "人事处"),
    TRAINING_DEPT(6, "教育培训处"),
    RETIRED_DEPT(7, "老干部处"),
    DISCIPLINE_INSPECTION(8, "直属机关纪委（警务督察室）"),
    EXECUTION_DEPT(9, "刑罚执行处"),
    PRISON_MANAGEMENT(10, "狱政管理处"),
    REFORM_EDU(11, "教育改造处"),
    PUBLIC_SECURITY(12, "公安处"),
    LIVING_HEALTH(13, "生活卫生处"),
    COMPREHENSIVE_GOV(14, "综合治理办公室"),
    LABOR_MANAGEMENT(15, "劳动管理处"),
    PLANNING_FINANCE(16, "计划财务处"),
    TECH_DEPT(17, "科技处"),
    GENERAL_MANAGEMENT(18, "综合管理处"),
    EQUIPMENT_DEPT(19, "装备处"),
    AUDIT_DEPT(20, "审计室"),
    UNION(21, "局工会"),
    PARTY_COMMITTEE(22, "局机关党委"),
    YOUTH_LEAGUE(23, "局团委"),
    SUPERVISION_INSPECTION(24, "监审视");

    private final int id;
    private final String name;

    DeptEnum(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() { return id; }

    public String getName() { return name; }

    public static List<DeptDTO> getAll() {
        List<DeptDTO> list = new ArrayList<>();
        for (DeptEnum dept : values()) {
            list.add(new DeptDTO(dept.id, dept.name));
        }
        return list;
    }

    // 根据id获取枚举实例
    public static DeptEnum getById(int id) {
        for (DeptEnum dept : values()) {
            if (dept.id == id) {
                return dept;
            }
        }
        return null;
    }

    // 根据id获取部门名称
    public static String getNameById(int id) {
        DeptEnum dept = getById(id);
        return dept != null ? dept.name : null;
    }
}
